﻿namespace EasyXaf.LowCode.WorkflowEditors.Models.Activities;

public static class ActivityGroupRegistrator
{
    private static readonly Dictionary<string, ActivityGroup> ActivityGroups = new();

    private static readonly ActivityGroup OtherGroup = new()
    {
        Name = ActivityGroupConsts.OtherGroupName,
        Caption = "其它",
        Order = int.MaxValue
    };

    public static void RegisterActivityGroup(ActivityGroup activityGroup)
    {
        ActivityGroups[activityGroup.Name] = activityGroup;
    }

    public static ActivityGroup GetActivityGroup(string groupName)
    {
        if (ActivityGroups.TryGetValue(groupName, out var activityGroup))
        {
            return activityGroup;
        }
        return OtherGroup;
    }
}
